import 'package:flutter/material.dart';

import '../../config/public_color.dart';
import '../../foundation/style/bold_text_style.dart';
import '../../foundation/style/public_button_style.dart';
import '../bar/public_app_bar.dart';

/// FileName action_button
///
/// @Author lax
/// @Date 2024/6/18
///
/// @Description

class ActionButton extends StatelessWidget {
  final EdgeInsets? margin;

  final EdgeInsets? padding;

  final VoidCallback? onPressed;

  final String? text;

  final TextStyle? textStyle;

  final Widget? child;

  const ActionButton({
    super.key,
    this.margin,
    this.padding = const EdgeInsets.symmetric(horizontal: 8),
    this.onPressed,
    this.text,
    this.textStyle,
    this.child,
  });

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: margin ?? EdgeInsets.zero,
      child: TextButton(
        style: PublicButtonStyle(padding: padding),
        onPressed: onPressed,
        child: child ??
            Text(
              text ?? '',
              style: textStyle ??
                  BoldTextStyle(
                      color: PublicAppBar.defaultTitleStyle?.color ??
                          PublicColor.darkText),
            ),
      ),
    );
  }
}
